package com.qolome.knowledge.concurrent;

/**
 * @author Qolome
 * @version V1.0
 * @description 活性失败 深度优化
 * @date 2020年 05月20日 20:46:11
 */
public class VolatileDemo {

    public  static boolean stop = false;
    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(()->{
            int i = 0;
            while (!stop){
                i++;
            }
            System.out.println("rs:"+i);
        });

        thread.start();
        Thread.sleep(1000);
        stop = true;
    }
}
